package br.edu.ufcg.splab.simulator;

import java.util.ArrayList;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;



import br.edu.ufcg.splab.core.InterfaceVertex;


public class TestGenerator {
	LTSGenerator generator = new LTSGenerator();
	
	InterfaceVertex root = generator.getGraphGenerator().getRoot();
	
	@Before
	public void creatGraph(){
		generator.getGraphGenerator().getStates().put(root.getUUID(), root);
	}
	
	@Test
	public void testGenerator() throws Exception{
		generator.addPath(root);
		
		Assert.assertEquals(generator.getGraphGenerator().getEdges().size(), 1);
		
		generator.addBranch(root);
		
		Assert.assertEquals(generator.getGraphGenerator().getEdges().size(), 3);
		
		generator.addLoop(root.getOutTransitions().get(0).getTo(), root);
		Assert.assertEquals(generator.getGraphGenerator().getEdges().size(), 4);
		
		ArrayList<InterfaceVertex> visitados = new ArrayList<InterfaceVertex>();
		generator.getPossibleLoop(root, visitados);
		Assert.assertTrue(visitados.isEmpty());
		
		generator.addPath(root.getOutTransitions().get(2).getTo());
		
		generator.getPossibleLoop(root.getOutTransitions().get(1).getTo(), visitados);
		Assert.assertFalse(visitados.isEmpty());
		
		System.out.println(generator.getGraphGenerator().getEdges().toString());
		System.out.println(visitados.toString());
		
		
		
		
			
	}
			}
